package com.example.myapplication;

import android.content.Context;

import com.jaredrummler.android.processes.AndroidProcesses;
import com.jaredrummler.android.processes.models.AndroidAppProcess;

import java.util.List;

/**
 * Created by xuanyang on 2018/3/13.
 */

public class Utils {

    public static String getTopStackPkg(Context context) {

        List<AndroidAppProcess> processes = AndroidProcesses.getRunningForegroundApps(context);
        for (AndroidAppProcess appProcess : processes) {
//            Log.i(Constants.LogTag, appProcess.getPackageName());
            if (appProcess.foreground) {
                if (appProcess.getPackageName().contains("com.tencent") || appProcess.getPackageName().contains("com.android")) {
                    continue;
                }
                return appProcess.getPackageName();
            }
        }
        return "";
    }
}
